package com.gitee.wsl.compose.ui.widget


import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.windowInsetsBottomHeight
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.pointer.pointerInput

/** Creates a spacer that respects the [navigation bars][WindowInsets.Companion.navigationBars]. */
@Composable
fun BottomSpacer(modifier: Modifier = Modifier) {
    Box(contentAlignment = Alignment.BottomStart, modifier = modifier) {
        Spacer(modifier = Modifier.navigationBarsPadding().imePadding())
        Spacer(
            modifier =
                Modifier.windowInsetsBottomHeight(WindowInsets.navigationBars)
                    .fillMaxWidth()
                    .pointerInput(Unit) {}
        )
    }
}
